package org.yellow.backend.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.yellow.backend.pojo.doctor;
import org.yellow.backend.service.doctorService;

import java.util.List;

/**
 * @author: hy
 * @create: 2024-01-01
 */
@Slf4j
@RestController
@RequestMapping("/doctor")
public class doctorController {
    @Autowired
    private doctorService service;
    @GetMapping("/{id}")
    public doctor getDoctor(@PathVariable("id") int id){
        log.info("查询编号为"+id+"的医生信息");
        return service.selectDocById(id);
    }

    @PostMapping("/update")
    public Boolean updateDoc(@RequestBody doctor doc){
        log.info("根据医生名更新新的医生信息为===>"+doc.toString());
        return service.updateDoc(doc);

    }
    @GetMapping("/dep/{depId}")
    public List<doctor> selectDocByDep(@PathVariable("depId") int depId){
        log.info("查询部门id为"+depId+"的医生列表");
        return service.selectDocByDep(depId);
    }
    @GetMapping("/appTime/{docId}")
    public String selectAppTime(@PathVariable("docId") int docId){
        log.info("查询医生编号为"+docId+"的可预约时间段");
        return service.selectAppTime(docId);
    }
    @GetMapping("/allDoc")
    public List<doctor> selectAllDoc(){
        return service.selectAllDoc();
    }
}
